<?php
function cmd_del($id)
{
   $sql = new db();
   $req = 'DELETE commande, ligne_commande FROM commande, ligne_commande WHERE commande.Id_Commande='.$id.' AND ligne_commande.Id_Commande='.$id;
   $sql->query($req);
   $hl = ABS_PATH.ROOT.'?page=Client/Commande&fct=Client/Commande';
   header("Location: $hl");
}

function cmd_val($id)
{
	$sql = new db();
	$req = "UPDATE commande SET Etat='c', Last_Mod=".time()." WHERE Id_Commande=".$id;
	$sql->query($req);
	$hl = ABS_PATH.ROOT.'?page=Client/Commande&fct=Client/Commande';
    header("Location: $hl");
}

function cmd_ref ($id)
{
	$sql = new db();
	$req = "UPDATE commande SET Etat='r', Last_Mod=".time()." WHERE Id_Commande=".$id;
	$sql->query($req);
	$hl = ABS_PATH.ROOT.'?page=Client/Commande&fct=Client/Commande';
    header("Location: $hl");
}

if (isset($_GET['id']) && !empty($_GET['id']) && isset($_GET['action']) && !empty($_GET['action']))
{
 switch ($_GET['action'])
 {
  case 'Delete':
   cmd_del($_GET['id']);
   break;
  case 'Accepte':
   cmd_val($_GET['id']);
   break;
  case 'Refuse':
   cmd_ref($_GET['id']);
   break;
 }
}

 ?>
	
	